<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="recordList">
      <!-- <el-table-column label="编号" align="center" prop="id" /> -->
      <el-table-column label="变更类型" align="center">
        <template slot-scope="scope">
          <p>{{ types[scope.row.changeType] }}</p>
        </template>

      </el-table-column>
      <el-table-column label="变更金额" align="center" prop="money" />
      <el-table-column label="变更原因" align="center" prop="reason" />
      <el-table-column label="操作时间" align="center" prop="updateTime" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listRecordByUser } from '@/api/finance/changeRecord'
import { ASSOC_SEARCH_BY_USER, INCOMING_AND_OUTGOING_ACCOUNTS, PROPS_ID, WATCH_ID } from '@/constant/const'
import { timestampToDate } from '@/utils/time'
export default {
  name: 'ChangeRecord',
  props: {
    ...PROPS_ID
  },
  watch: {
    ...WATCH_ID
  },

  data() {
    return {
      // 遮罩层
      loading: true,
      types: INCOMING_AND_OUTGOING_ACCOUNTS,
      // 选中数组
      // 总条数
      total: 0,
      recordList: [],
      // 查询参数
      queryParams: { ...ASSOC_SEARCH_BY_USER }
    }
  },

  mounted() {
    this.getList(null)
  },

  methods: {
    timestampToDate,

    /** 查询订单列表 */
    getList(dateRange) {
      this.loading = true

      if (dateRange) {
        this.queryParams.startTime = dateRange[0] ? new Date(dateRange[0]).getTime() / 1000 : '';
        this.queryParams.endTime = dateRange[1] ? new Date(dateRange[1]).getTime() / 1000 : '';
      }
      console.log("this.queryParams", this.queryParams);
      listRecordByUser(this.queryParams).then((response) => {
        this.recordList = response.rows
        this.recordList.forEach((item) => {
          item.updateTime = timestampToDate(item.updateTime)
        })
        this.total = response.total
        this.loading = false
      })
    }
  }
}
</script>

<style></style>
